<template>
  <div ref="wrapEl">
    <AdTable @register="registerTable">
      <!-- <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'action'">
          <TableAction :stop-button-propagation="true" :actions="[]" />
        </template>
      </template> -->
    </AdTable>
  </div>
</template>

<script lang="ts">
  import { defineComponent, ref } from 'vue';
  import { Authority } from '@/components/Authority';
  import { AdTable, useAdTable, TableAction } from '@/components/AdTable';
  import { useLoading } from '@/components/Loading';
  import { useMessage } from '@/hooks/web/useMessage';
  import { FormModeEnum } from '@/enums/formEnum';
  import { AjaxResultTypeEnum } from '@/enums/ajaxResultTypeEnum';
  import { ImageSelector } from '@/components/ImageSelector';
  import Icon from '@/components/Icon/Icon.vue';
  import { columns } from './material.data';
  import { Read, Create, Update, Delete } from './material.api';

  export default defineComponent({
    name: 'MaterialPage',
    components: {
      Authority,
      AdTable,
      TableAction,
      Icon,
      ImageSelector,
    },
    setup() {
      const { createMessage } = useMessage();
      const wrapEl = ref<ElRef>(null);
      const [openWrapLoading, closeWrapLoading] = useLoading({
        target: wrapEl,
        props: {
          tip: '加载中...',
          absolute: true,
        },
      });

      const [registerTable, { openDetailForm, reload }] = useAdTable({
        // 表标题呈现器
        title: '仓储列表',
        // 表格数据接口请求对象
        api: Read,
        // 表单列信息 BasicColumn[]
        columns,
        // 是否可拖拽列
        canColDrag: true,
        // 使用搜索表单
        useSearchForm: true,
        // 显示表格设置工具
        showTableSetting: true,
        //表格设置项
        tableSetting: { redo: true, size: true, setting: true, fullScreen: true },
        // 是否显示表格边框
        bordered: true,
        // 是否显示序号列
        showIndexColumn: true,
        actionColumn: {
          defaultHidden: true,
        },
      });

      return {
        wrapEl,
        registerTable,
      };
    },
  });
</script>
